package com.rc.saas.mini.vo.order;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.rc.saas.mini.model.invoice.InvoiceApply;
import com.rc.saas.mini.model.order.OrderInfo;
import com.rc.saas.mini.model.order.OrderRefundApply;
import com.rc.saas.mini.model.order.OrderRefundApplyExample;
import com.rc.saas.mini.vo.invoice.InvoiceApplyWithIdVo;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

/**
 * @author wangzhengwei
 * @create 2021/4/23
 */
public class OrderInfoVo extends OrderInfo {
    /**
     * 枪编号
     */
    @ApiModelProperty(value = "枪编号")
    private String gunNo;

    /**
     * 桩编号
     */
    @ApiModelProperty(value = "桩编号")
    private String pileNo;

    /**
     * 桩名
     */
    @ApiModelProperty(value = "桩名")
    private String elecPileName;

    /**
     * 站名
     */
    @ApiModelProperty(value = "站名")
    private String elecStationName;


    /**
     * 站名
     */
    @ApiModelProperty(value = "站地址")
    private String address;

    /**
     * 枪顺序号
     */
    @ApiModelProperty(value = "枪顺序号")
    private String gunNum;

    @ApiModelProperty(value = "订单最新申请发票数据")
    private InvoiceApplyWithIdVo invoiceApplyWithIdVo;

    @ApiModelProperty(value = "订单最新申请退款数据")
    private OrderRefundApply orderRefundApply;

    @ApiModelProperty(value = "剩余充电时间")
    private String surplusTime = "";

    @ApiModelProperty(value = "充电时长时间")
    private String durationTime = "";

    @ApiModelProperty(value = "0快，1慢")
    private String pileType = "0";

    @ApiModelProperty(value = "结算时间(弃用)")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date payTime;

    @ApiModelProperty(value = "评价时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date evaluateTime;

    public Date getEvaluateTime() {
        return evaluateTime;
    }

    public void setEvaluateTime(Date evaluateTime) {
        this.evaluateTime = evaluateTime;
    }

    public String getPileType() {
        return pileType;
    }

    public void setPileType(String pileType) {
        this.pileType = pileType;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getSurplusTime() {
        return surplusTime;
    }

    public void setSurplusTime(String surplusTime) {
        this.surplusTime = surplusTime;
    }

    public String getDurationTime() {
        if (this.getEndTime() != null && this.getStartTime() != null) {
            return second2Time((this.getEndTime().getTime() - this.getStartTime().getTime()) / 1000);

        } else if (this.getStartTime() != null) {
            return second2Time((System.currentTimeMillis() - this.getStartTime().getTime()) / 1000);
        }
        return durationTime;
    }

    public Date getPayTime() {
        this.payTime = this.getOccupyPayTime();
        if (this.payTime == null) {
            return getEndTime();
        }
        return payTime;
    }

    public void setPayTime(Date payTime) {
        this.payTime = payTime;
    }

    public void setDurationTime(String durationTime) {
        this.durationTime = durationTime;
    }

    public InvoiceApplyWithIdVo getInvoiceApplyWithIdVo() {
        return invoiceApplyWithIdVo;
    }

    public void setInvoiceApplyWithIdVo(InvoiceApplyWithIdVo invoiceApplyWithIdVo) {
        this.invoiceApplyWithIdVo = invoiceApplyWithIdVo;
    }

    public OrderRefundApply getOrderRefundApply() {
        return orderRefundApply;
    }

    public void setOrderRefundApply(OrderRefundApply orderRefundApply) {
        this.orderRefundApply = orderRefundApply;
    }

    public String getGunNo() {
        return gunNo;
    }

    public void setGunNo(String gunNo) {
        this.gunNo = gunNo;
    }

    public String getPileNo() {
        return pileNo;
    }

    public void setPileNo(String pileNo) {
        this.pileNo = pileNo;
    }

    public String getElecPileName() {
        return elecPileName;
    }

    public void setElecPileName(String elecPileName) {
        this.elecPileName = elecPileName;
    }

    public String getElecStationName() {
        return elecStationName;
    }

    public void setElecStationName(String elecStationName) {
        this.elecStationName = elecStationName;
    }

    public String getGunNum() {
        return gunNum;
    }

    public void setGunNum(String gunNum) {
        this.gunNum = gunNum;
    }

    public static String second2Time(Long second) {
        if (second == null || second < 0) {
            return "00:00:00";
        }

        long h = second / 3600;
        long m = (second % 3600) / 60;
        long s = second % 60;
        String str = "";

        str = (h < 10 ? ("0" + h) : h) + ":";
        str += (m < 10 ? ("0" + m) : m) + ":";
        str += (s < 10 ? ("0" + s) : s);
        return str;

    }
}
